package com.yanq.liancar.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yanq.liancar.R;
import com.yanq.liancar.activity.BindOBDActivity;
import com.yanq.liancar.activity.CarDoctorActivity;
import com.yanq.liancar.activity.MyOBDActivity;
import com.yanq.liancar.bean.FindMsgBean;
import com.yanq.liancar.bean.OBDBean;
import com.yanq.liancar.util.Constant;
import com.yanq.liancar.view.recyclerview.RecyclerAdapter;
import com.yanq.liancar.view.recyclerview.RecyclerHolder;
import com.yanq.liancar.view.recyclerview.RecyclerListener;

import java.util.List;

public class OBDAdapter extends RecyclerAdapter<OBDBean.DataBean> implements RecyclerListener.OnClickListener<RecyclerHolder> {

    public OBDAdapter(Context context, List<OBDBean.DataBean> data) {
        super(context, data, R.layout.item_myobd);
    }

    @Override
    public void convert(RecyclerHolder holder, OBDBean.DataBean model) {
        holder.setTvText(R.id.obd_num, "OBD: " + model.getOdbNum());
        OBDBean.DataBean.UserCarBean userCar = model.getUserCar();
        holder.setTvText(R.id.obd_car, "绑定车辆: " + userCar.getDriNum());
        holder.setOnClickListener(this, R.id.obd_root, R.id.chakan);
    }

    @Override
    public void onClick(View v, int position, RecyclerHolder holder) {
        switch (v.getId()) {
            case R.id.obd_root:
                OBDBean.DataBean dataBean = mData.get(position);
                OBDBean.DataBean.UserCarBean userCar = dataBean.getUserCar();
                BindOBDActivity.start(mContext, dataBean.getId(), dataBean.getOdbNum(), userCar.getDriNum());
//                Intent intent = new Intent(mContext, BindOBDActivity.class);
//                Bundle bundle = new Bundle();
//                bundle.putInt("OBDPos", position);
//                intent.putExtras(bundle);
//                mContext.startActivity(intent);
                break;
            case R.id.chakan:
                mContext.startActivity(new Intent(mContext, CarDoctorActivity.class));
                break;
        }
    }
}